package com.hrt.datasender.web.bcsendplatformparam;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.btcode.db.result.Row;
import com.btcode.web.core.annotation.RequestMapping;
import com.btcode.web.core.controller.Controller;
import com.hrt.common.web.DSRequestUnit;
import com.hrt.datasender.datadao.model.BcSendPlatformModel;
import com.hrt.datasender.datadao.model.BcSendPlatformParamModel;
import com.hrt.datasender.datadao.service.BcSendPlatformParamService;
import com.hrt.db.DBManager;

@RequestMapping(path = "BCSendPlatformParam")
public class BCSendPlatformParamController extends Controller {

    @RequestMapping(path = "getModelList")
    public void getModelList(ServletRequest arg0, ServletResponse arg1) throws IOException {
        String platFormID = DSRequestUnit.getParameter("PLATFORM_ID");
        List<BcSendPlatformParamModel> list = BcSendPlatformParamService.getInstance().getPlatformParam(platFormID);
        success(list);
    }

    @RequestMapping(path = "getListForReport")
    public void getListForReport(ServletRequest arg0, ServletResponse arg1) throws IOException {
        String platFormID = DSRequestUnit.getParameter("PLATFORM_ID");
        List<Row> list = BcSendPlatformParamService.getInstance().getPlatformParamForReport(platFormID);
        success(list);
    }

    @RequestMapping(path = "saveModel")
    public void saveModel(ServletRequest arg0, ServletResponse arg1) throws IOException {
        BcSendPlatformParamModel model = DSRequestUnit.getModel(BcSendPlatformParamModel.class);
        BcSendPlatformParamService.getInstance().save(model);
        success(model);
    }

    @RequestMapping(path = "updateModel")
    public void updateModel(ServletRequest arg0, ServletResponse arg1) throws IOException {
        BcSendPlatformModel model = DSRequestUnit.getModel(BcSendPlatformModel.class);
        DBManager.getORMExecuter().update(model);
        success(model);

    }

    @RequestMapping(path = "deleteModel")
    public void deleteModel(ServletRequest arg0, ServletResponse arg1) throws IOException {
        String platFormID = DSRequestUnit.getParameter("PLATFORM_ID");
        BcSendPlatformParamService.getInstance().delete(platFormID);
        success("");
    }
}
